/**
 * 
 */
package cn.jdbc.controller;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.ws.rs.PathParam;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;

import cn.jdbc.pojo.Invitation;
import cn.jdbc.service.invitation.InvitationService;
import cn.jdbc.service.reply.ReplyService;

/**
 * @author Invitation
 * 
 */
@Controller
public class InvitationController {
	@Resource
	private InvitationService invitationService;
	@Resource
	private ReplyService replyService;
	@RequestMapping(value = "/invitationlist.html")
	public String getInvitation(Model model) {
		List<Invitation> invitationLsit = invitationService.getInvitationList();
		model.addAttribute("invitationLsit", invitationLsit);
		for (Invitation invitation : invitationLsit) {
			System.out.println(invitation.getId()+"=======>"+invitation.getTitle()+"======>"+invitation.getSummary());
		}
		return "Invitation";
	}

	@RequestMapping(value = "/delIn/{lid}")
	@ResponseBody
	public Object deleteIn(@PathVariable int lid) {
		HashMap<String, String> delMap = new HashMap<String, String>();
		if (replyService.deleteRely(lid)) {
			if (invitationService.deleteInvitation(lid)) {
				delMap.put("delResult", "true");
			}
		}else{
			delMap.put("delResult", "false");
		}
		return JSONArray.toJSONString(delMap);
	}
}
